package com.linktel.productionLine.controller;

import com.linktel.productionLine.common.BaseResponse;
import com.linktel.productionLine.common.ErrorCode;
import com.linktel.productionLine.common.ResultUtils;
import com.linktel.productionLine.entity.dto.productionPanel.EfficiencyCurveCharDTO;
import com.linktel.productionLine.entity.dto.productionPanel.StatisticCardsDTO;
import com.linktel.productionLine.entity.dto.productionPanel.StepProductDetailDTO;
import com.linktel.productionLine.exception.BusinessException;
import com.linktel.productionLine.service.ProductionPanelService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author HuangJiaHui
 * @Date 2023/10/19 16:53
 */
@RestController
@RequestMapping("/production-panel")
@AllArgsConstructor
public class ProductionPanelController {
    private ProductionPanelService productionPanelService;

    /**
     * 查询规划基础数据
     * @param productionLineCode 产线编码
     * @return 规划基础数据
     */
    @GetMapping("/statisticCards")
    public BaseResponse<StatisticCardsDTO> getStatisticCards(String productionLineCode) {
        if (productionLineCode == null || "".equals(productionLineCode)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "产线选择不能为空");
        }
        StatisticCardsDTO statisticCards = productionPanelService.getStatisticCards(productionLineCode);
        return ResultUtils.success(statisticCards);
    }
    @GetMapping("/stepProductDetailDTO")
    public BaseResponse<List<StepProductDetailDTO>> listStepProductDetail(String productionLineCode) {
        if (productionLineCode == null || "".equals(productionLineCode)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "产线选择不能为空");
        }
        List<StepProductDetailDTO> stepProductDetailDTOS = productionPanelService.listStepProductDetail(productionLineCode);
        return ResultUtils.success(stepProductDetailDTOS);
    }
    @GetMapping("/efficiencyCurveCharDTO")
    public BaseResponse<List<EfficiencyCurveCharDTO>> listEfficiencyCurveChar(String productionLineCode) {
        if (productionLineCode == null || "".equals(productionLineCode)) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR, "产线选择不能为空");
        }
        List<EfficiencyCurveCharDTO> efficiencyCurveCharDTOS = productionPanelService.listEfficiencyCurveChar(productionLineCode);
        return ResultUtils.success(efficiencyCurveCharDTOS);
    }
}
